package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.demo.entity.TimeSheet;
import com.example.demo.mapper.TimeSheetMapper;
import com.example.demo.service.ITimeSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class TimeSheetService implements ITimeSheetService {

    @Autowired
    TimeSheetMapper timeSheetMapper;

    /**
     * 查询时间表
     *
     * @param version 版本
     * @return
     */
    @Override
    public Optional<List<TimeSheet>> selectListByVersion(String version) {
        LambdaQueryWrapper<TimeSheet> wrapper = new LambdaQueryWrapper();
        wrapper.eq(TimeSheet::getStatus, 1) // 有效
                .eq(TimeSheet::getVersion, version); // 版本
        Optional<List<TimeSheet>> timeSheets = Optional.ofNullable(timeSheetMapper.selectList(wrapper));
        return timeSheets;
    }
}
